package com.bonorsoft.pay.controller;

import com.bonorsoft.common.api.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @description
 * @auth WilliamYe
 * @date 2021/8/31
 * @time 15:22
 */
@RestController
@RequestMapping(("/api"))
public class ApiBaseController {

    @Autowired(required = false)
    public HttpServletRequest request;

    @Autowired(required = false)
    public HttpServletResponse response;

    /**
     * 处理上传异常
     * @param t
     * @return
     */
    @ExceptionHandler(MultipartException.class)
    public Result handleAll(Throwable t)throws Exception{
        t.printStackTrace();
        return Result.error(408,"文件上传出现异常");
    }
}

